# U1
#file(GLOB_RECURSE SOURCES
#        "../../startup/startup_gd32f450.S"
#        "Src/*.c"
#        )

# U2
file(GLOB_RECURSE SOURCES
        "../../startup/startup_gd32f450.S"
        "Src/*.c"
        )

file(GLOB_RECURSE HEADERS
        "Inc/*.h"
        )


add_link_options(-T ${LINKER_SCRIPT})

# U1
#add_executable(smartLED.elf ${SOURCES} ${HEADERS} ${LINKER_SCRIPT})

# U2
add_executable(smartLED.elf ${SOURCES} ${HEADERS} ${LINKER_SCRIPT})

target_include_directories(smartLED.elf PRIVATE Inc)

# U1
target_link_libraries(smartLED.elf MyLibrary CMSISLibrary PeripheralsLibrary)

# U2
#target_link_libraries(smartLED.elf MyLibrary CMSISLibrary PeripheralsLibrary)

set(HEX_FILE ${PROJECT_BINARY_DIR}/LED.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/LED.bin)

add_custom_command(TARGET smartLED.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:smartLED.elf> ${HEX_FILE}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:smartLED.elf> ${BIN_FILE}
        COMMENT "Building ${HEX_FILE} Building ${BIN_FILE}")